<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="myCss/flex.css" />
		<link rel="stylesheet" href="css/iconfont.css" />
		<style type="text/css">
			body {
				background-color: #FFFFFF;
			}
			
			.text-center {
				text-align: center;
				margin-top: 5px;
			}
			
			.icon-size {
				font-size: 23px;
			}
			
			.text-center>p {
				margin: 0px;
			}
			
			.mui-bar>div {
				margin-top: 9px;
			}
			
			.flex-row>a>p {
				margin-top: 5px;
				color: #000000;
			}
			
			.flex-row>a>p~p {
				margin-top: 0px;
			}
			/*.mui-bar {
				box-shadow: none;
			}*/
			
			#nologin>span:active {
				color: #0099ff;
			}
			
			.mui-bar .mui-title {
				right: 5em;
				left: 5em;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" style="background-color: #FFFFFF;">
			<h1 class="mui-title">钓鱼帮</h1>
			<div id="nologin" style="line-height: 32px;display:inline-block;width: 300px;">
				<span id="userLogin">登录</span>
				<span id="userRegister">注册</span>
			</div>

			<div id="login" style="line-height: 35px;display:none">
				<img id="userImg"  width="30px" height="30px" style="margin-right: 10px;border-radius: 1rem;" />
				<span id="nickname" style="position: relative;bottom: 10px;">用户名</span>
			</div>
		</header>
		<nav class="mui-bar mui-bar-tab flex-row" style="">
			<a id="subIndex" href="HTML/subIndex.html" class="text-center" style="color: #0099ff;">
				<p class="child-el iconfont icon-daohangshouye icon-size" style="color: #0099ff;"></p>
				<p class="child-el mui-tab-label" style="color: #0099ff;">首页</p>
			</a>
			<a id="fishPlace" href="HTML/fishPlace.html" class="text-center">
				<p class="child-el iconfont icon-location icon-size" style="font-size: 25px;"></p>
				<p class="child-el mui-tab-label">钓点</p>
			</a>
			<a id="mine" href="HTML/mine.html" class="text-center">
				<p class="child-el iconfont icon-wode icon-size"></p>
				<p class="child-el mui-tab-label">我的</p>
			</a>
		</nav>
		<script src="js/mui.min.js"></script>
		<script type="text/javascript" src="js/base64.min.js"></script>
		<script type="text/javascript" src="js/md5.min.js"></script>
		<script type="text/javascript" charset="utf-8">
			var subpages = ['HTML/subIndex.html', 'HTML/fishPlace.html', 'HTML/mine.html'];
			var subpage_style = {
				top: '45px',
				bottom: '45px'
			};
			var subIndex = null;
			var fishPlace = null;
			var mine = null;
			mui.init();
			//重写返回时间
			mui.back = function() {
				plus.nativeUI.confirm("是否退出应用？", function(e) {
					if(e.index == 0) {
						plus.runtime.quit();
					}
				}, "退出");
			}
			//子页面切换
			var activeTab = subpages[0];
			mui(".mui-bar-tab").on("tap", "a", function() {
				var targetTab = this.getAttribute('href');
				if(targetTab == activeTab) {
					return;
				}
				var self = plus.webview.currentWebview();
				var sub = plus.webview.create(targetTab, targetTab, subpage_style);
				self.append(sub);
				//隐藏当前;    
				plus.webview.hide(activeTab);
				//更改当前活跃的选项卡    
				activeTab = targetTab;
				var childEl = document.querySelectorAll(".child-el");
				for(var i = 0; i < childEl.length; i++) {
					childEl[i].style.color = "#000000";
				}
				var thisChild = document.getElementById(this.id);
				thisChild.children[0].style.color = "#0099FF";
				thisChild.children[1].style.color = "#0099FF";
			})
			//注册和登录
			document.getElementById("userLogin").addEventListener("tap", function() {
				//				console.log("登录");
				mui.openWindow({
					url: "HTML/login.html",
					id: "login"
				})
			})
			document.getElementById("userRegister").addEventListener("tap", function() {
				//				console.log("注册");
				mui.openWindow({
					url: "HTML/resign.html",
					id: "resign"
				})

			})
			//登录回调
			function hideLog(nickname,headimgurl) {
				var userImg= document.getElementById("userImg");
				login.style.display = "block";
				nologin.style.display = "none";
				userImg.src=headimgurl;
				document.getElementById("nickname").innerText=nickname;
			}
			//注销回调
			function LogFn() {
				plus.nativeUI.confirm("是否注销？", function(e) {
					if(e.index == 0) {
						login.style.display = "none";
						nologin.style.display = "block";
						plus.storage.removeItem("account");
						plus.storage.removeItem("password");
						plus.storage.removeItem("userId");
					}
				})
			}
			mui.plusReady(function() {
				//从本地缓存中获取用户令牌信息，通过令牌可以获取用户信息  
				//				var userToken = window.localStorage.getItem("userToken");
				//				if(userToken == null || userToken == "" || userToken.length == 0) {
				//					goToLogin();
				//				} 
				var userAccoun = plus.storage.getItem("contantAccount");
				var userPassword = plus.storage.getItem("contantPassword");
				if(userAccoun === null) {
					//console.log(userAccoun === null);
					document.getElementById("login").style.display = "none";
					document.getElementById("nologin").style.display = "inline-block";
				} else {
					document.getElementById("login").style.display = "inline-block";
					document.getElementById("nologin").style.display = "none";
				}
				var self = plus.webview.currentWebview();
				for(var i = 0; i < 1; i++) { //这里只加载第一个页面    
					var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);
					if(i > 0) {
						sub.hide();
					}
					self.append(sub);
				}
			})
		</script>
	</body>

</html>